package cn.bluethink.eguan.core.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;

import cn.bluethink.eguan.model.core.EgActionFlag;
import cn.bluethink.eguan.model.core.EgObject;

/**
 * 用户操作对象的动作实体
 * 
 * @author 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.2.0
 * @brief 驿馆+（EGUAN）
 * @note 修订历史： 1、wanglei于2018/11/08设计并构建初始版本v0.2.0
 */
@Table(name = "eg_action")
public class EgActionEntity implements Serializable {

    private static final long serialVersionUID = -20573245347262633L;

    // 动作ID
    @Id
    private Long aid;

    // 动作类型ID
    private Integer atid;

    // 被操作的对象类型ID
    private Integer otype;

    // 被操作的对象ID
    private Long oid;

    // 被操作的对象名称
    private String oname;

    // 操作的结果对象类型ID
    private Integer rtype;

    // 操作的结果对象的ID
    private Long roid;

    // 操作结果
    private String rcontent;

    // 被操作对象名称
    private String rname;

    // 动作发生的位置对象类型
    @Column(name = "pos_otype")
    private Integer posOtype;

    // 动作发生的位置对象ID
    @Column(name = "pos_oid")
    private Long posOid;

    // 执行操作者的ID
    private Long uid;

    // 操作的时间
    private Date ctime;

    // 动作标识
    @Column(name = "act_flag")
    private Integer actFlag;

    public EgActionEntity() {
    }

    public EgActionEntity(Integer atid, EgObject obj, EgObject result, String rcontent, EgObject pos, Long uid,
            Integer actFlag) {
        this.atid = atid;
        this.otype = obj.getType().getOtid();
        this.oid = obj.getId();
        this.oname = obj.getName();
        this.rtype = result == null ? null : result.getType().getOtid();
        this.roid = result == null ? null : result.getId();
        this.rname = result == null ? null : result.getName();
        this.rcontent = rcontent;
        this.posOtype = pos == null ? null : pos.getType().getOtid();
        this.posOid = pos == null ? null : pos.getId();
        this.uid = uid;
        this.actFlag = actFlag == null ? (EgActionFlag.OPREATE | EgActionFlag.DYNAMIC) : actFlag;
    }

    public Long getAid() {
        return aid;
    }

    public void setAid(Long aid) {
        this.aid = aid;
    }

    public Integer getAtid() {
        return atid;
    }

    public void setAtid(Integer atid) {
        this.atid = atid;
    }

    public Integer getOtype() {
        return otype;
    }

    public void setOtype(Integer otype) {
        this.otype = otype;
    }

    public Long getOid() {
        return oid;
    }

    public void setOid(Long oid) {
        this.oid = oid;
    }

    public String getOname() {
        return oname;
    }

    public void setOname(String oname) {
        this.oname = oname;
    }

    public Integer getRtype() {
        return rtype;
    }

    public void setRtype(Integer rtype) {
        this.rtype = rtype;
    }

    public Long getRoid() {
        return roid;
    }

    public void setRoid(Long roid) {
        this.roid = roid;
    }

    public String getRcontent() {
        return rcontent;
    }

    public void setRcontent(String rcontent) {
        this.rcontent = rcontent;
    }

    public Integer getPosOtype() {
        return posOtype;
    }

    public void setPosOtype(Integer posOtype) {
        this.posOtype = posOtype;
    }

    public Long getPosOid() {
        return posOid;
    }

    public void setPosOid(Long posOid) {
        this.posOid = posOid;
    }

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

    public String getRname() {
        return rname;
    }

    public void setRname(String rname) {
        this.rname = rname;
    }

    public Integer getActFlag() {
        return actFlag;
    }

    public void setActFlag(Integer actFlag) {
        this.actFlag = actFlag;
    }

}
